cap log close

global path = "****"
local name= "baseline_mort_1718"
local date = "060920"
global logname = "$path/`name'_`date'.log"

clear
set more off
cd "$path"
log using "$logname", replace

use "$path/Data/penalty_sample.dta", clear

* Sample restrictions: penalty group; 45-64 year olds & no full coverage in 2016
keep if age_2017>=45 & age_2017<65
keep if notall16 == 1

* Duplicate observations
expand 2, gen(B)
gen A = B == 0

* Create a new outcome variable
gen	    L = dead1718 		if A == 1
replace L = any_covered1718 if B == 1

* Regression
gen Z_A   = treatment*A
gen C_A	  = any_covered1718*A
gen C_Z_A = any_covered1718*treatment*A
gen Z_B   = treatment*B

reg L A Z_A C_A C_Z_A B Z_B, nocons cluster(tin)
eststo stacked

* save as .ster
estimates save "$path/`name'_`date'.ster", replace


log close


